<?php
namespace App\Http\Controllers\blog\front\contab;

use App\Http\Controllers\blog\Controller;
use App\Model\front\UserModel;
use Symfony\Component\HttpFoundation\Request;
use Mail;

class SendEmailController extends Controller{

	//邮件发送
	public function SendEmail($data=[])
	{
			Mail::send('activemail', $data, function($message) use($data)
			{
			    $message->to($data['email'], $data['name'])->subject("欢迎注册Gelei's Blog，请激活您的账号！");
			});
	}

	//邮箱验证
	public function verifyEmail(Request $request)
	{
		$user_id = $request->get('uid');
		$action_code = $request->get('activationcode');
		$where = ['user_id'=>$user_id,'action_code'=>$action_code];
		$User = new UserModel();
		$res = $User->activeEmail($where);
		if ($res) {
			$info = '立即登录';
			$status = '1';
			return view('blog/front/contab/verify')->with(compact('info','status'));
		}
		$info = '账号激活失败';
		$status = '0';

		return view('blog/front/contab/verify')->with(compact('info','status'));
	}
}